import { delay } from 'roadhog-api-doc';
import Mock from 'mockjs';
export default delay({
  'Post /umi/goodsList': (req, res) => {
    const { page = 1, limit = 9 } = req.body;
    const toalPage = 3; // 设定总页数
    const lastPageLimit = 2; // 设定尾页条数
    const total = limit * (toalPage - 1) + lastPageLimit;  //计算总条数 减一是最后一页没算另外加上 2
    res.send({
      code: 0,
      data: {
        page,
        limit,
        total,
        ...Mock.mock({
          [`data|${page >= toalPage ? lastPageLimit : limit}`]: [
            {
              'id|+1': 1,
              create_at: '@date(yy-MM-dd HH:mm:ss)',
              'type_str|1': [
                '中转费明细',
                '客户费明细',
                '调整单费明细',
              ],
              operation: '@cname',
              'state|1': [0, 1, 2, 3]
            }
          ]
        })
      }
    });
  }
}, 1000
);